
use VSG_Original.dta, clear

drop if weight_genpop_2020Sep == .
svyset[pweight=weight_genpop_2020Sep]

* Demographic Controls
gen age = .
sum birthyr_2020Sep if birthyr_2020Sep < 9998
replace age = ((birthyr_2020Sep - `r(min)') / (`r(max)'-`r(min)')) if birthyr_2020Sep < 9998

gen white = 0
replace white = 1 if race_2020Sep == 1
gen black = 0
replace black = 1 if race_2020Sep == 2
gen hispanic = 0
replace hispanic = 1 if race_2020Sep == 3

gen male = 0
replace male = 1 if gender_2020Sep == 1

gen income = (faminc_2020Sep-1)/15 if faminc_2020Sep < 30

gen unemployed = 0
replace unemployed = 1 if employment_2020Sep == 4 | employment_2020Sep == 3

gen parent = 0
replace parent = 1 if household_child_num_2020Sep >= 1

gen education = (educ_2020Sep-1)/5 if educ_2020Sep < 7

gen south = 0
replace south = 1 if inputstate_2020Sep == 1.inputstate_2020Sep | 5.inputstate_2020Sep | 10.inputstate_2020Sep | 11.inputstate_2020Sep | 12.inputstate_2020Sep | 13.inputstate_2020Sep | 21.inputstate_2020Sep | 22.inputstate_2020Sep | 24.inputstate_2020Sep | 28.inputstate_2020Sep | 37.inputstate_2020Sep | 40.inputstate_2020Sep | 45.inputstate_2020Sep | 47.inputstate_2020Sep | 48.inputstate_2020Sep | 51.inputstate_2020Sep | 54.inputstate_2020Sep

* Authoritarianism 
gen auth1_2016 = .
replace auth1_2016 = 0 if sc1_independent_2016 == 1
replace auth1_2016 = 1 if sc1_independent_2016 == 2
gen auth2_2016 = .
replace auth2_2016 = 0 if sc2_curiosity_2016 == 1
replace auth2_2016 = 1 if sc2_curiosity_2016 == 2
gen auth3_2016 = .
replace auth3_2016 = 0 if sc3_obedience_2016 == 2
replace auth3_2016 = 1 if sc3_obedience_2016 == 1
gen auth4_2016 = .
replace auth4_2016 = 0 if sc4_considerate_2016 == 1
replace auth4_2016 = 1 if sc4_considerate_2016 == 2
alpha auth1_2016-auth4_2016, gen(auth_2016)

* Political Interest 
gen interest_2016 = 1-(newsint_2016-1)/3 if newsint_2016 < 5
gen interest_2017 = 1-(newsint_2017-1)/3 if newsint_2017 < 5
gen interest_2018 = 1-(newsint_2018-1)/3 if newsint_2018 < 5
gen interest_2019Jan = 1-(newsint_2019Jan-1)/3 if newsint_2019Jan < 5
gen interest_2019Nov = 1-(newsint_2019Nov-1)/3 if newsint_2019Nov < 5
gen interest_2020Sep = 1-(newsint_2020Sep-1)/3 if newsint_2020Sep < 5
alpha interest_2016 interest_2017 interest_2018 interest_2019Jan interest_2019Nov interest_2020Sep, gen(interest)

* Political Knowledge
gen know1 = 0 if polknow_senterm_2019Jan != .
replace know1 = 1 if polknow_senterm_2019Jan == 6
gen know2 = 0 if polknow_housemaj_2019Jan != .
replace know2 = 1 if polknow_housemaj_2019Jan == 2
gen know3 = 0 if polknow_senmaj_2019Jan != .
replace know3 = 1 if polknow_senmaj_2019Jan == 1
gen know4 = 0 if polknow_may_2019Jan != .
replace know4 = 1 if polknow_may_2019Jan == 3
gen know5 = 0 if polknow_gorsuch_2019Jan != .
replace know5 = 1 if polknow_gorsuch_2019Jan == 3
gen know6 = 0 if polknow_override_2019Jan != .
replace know6 = 1 if polknow_override_2019Jan == 3
gen know7 = 0 if polknow_declarewar_2019Jan != .
replace know7 = 1 if polknow_declarewar_2019Jan == 2

alpha know1-know7, gen(knowledge)

* Political Engagement 
alpha interest knowledge, gen(engagement)

* Party ID and Ideology
gen pid01 = (pid7_2020Sep-1)/6 if pid7_2020Sep < 8
replace pid01 = .5 if pid7_2020Sep == 8

gen ideo01 = (ideo5_2020Sep-1)/4 if ideo5_2020Sep < 6
replace ideo01 = .5 if ideo5_2020Sep == 6

alpha pid01 ideo01, gen(leftright_scale)

svy: regress leftright_scale c.auth_2016##c.engagement age male black hispanic education income unemployed south 
* Confirms authoritarianism was conditionally associated with right-wing identification at high political engagement. 

* COVID Concern
gen covidconcern = .
replace covidconcern = 1-(covid_concern_2020Sep-1)/3

* COVID Public Health Restrictions
gen staterestrictions = .
replace staterestrictions = 0 if covid_endrestrictions_2020Sep == 2
replace staterestrictions = 1 if covid_endrestrictions_2020Sep == 1
gen cancelevents = .
replace cancelevents = 1-(covid_restrict_gathering_2020Sep-1)/3 if covid_restrict_gathering_2020Sep < 5
replace cancelevents = .5 if covid_restrict_gathering_2020Sep == 5
gen businessclosures = .
replace businessclosures = 1-(covid_restrict_business_2020Sep-1)/3 if covid_restrict_business_2020Sep < 5
replace businessclosures = .5 if covid_restrict_business_2020Sep == 5
gen schoolclosures = .
replace schoolclosures = 1-(covid_restrict_school_2020Sep-1)/3 if covid_restrict_school_2020Sep < 5
replace schoolclosures = .5 if covid_restrict_school_2020Sep == 5
gen workfromhome = .
replace workfromhome = 1-(covid_restrict_wfh_2020Sep-1)/3 if covid_restrict_wfh_2020Sep < 5
replace workfromhome = .5 if covid_restrict_wfh_2020Sep == 5
gen travelrestrictions = .
replace travelrestrictions = 1-(covid_restrict_travel_2020Sep-1)/3 if covid_restrict_travel_2020Sep < 5
replace travelrestrictions = .5 if covid_restrict_travel_2020Sep == 5
gen stayhome = .
replace stayhome = 1-(covid_restrict_stayhome_2020Sep-1)/3 if covid_restrict_stayhome_2020Sep < 5
replace stayhome = .5 if covid_restrict_stayhome_2020Sep == 5
gen testingreq = .
replace testingreq = 1-(covid_restrict_test_2020Sep-1)/3 if covid_restrict_test_2020Sep < 5
replace testingreq = .5 if covid_restrict_test_2020Sep == 5

factor staterestrictions cancelevents businessclosures schoolclosures workfromhome travelrestrictions stayhome testingreq [aweight=weight_genpop_2020Sep], pcf
alpha staterestrictions cancelevents businessclosures schoolclosures workfromhome travelrestrictions stayhome testingreq, gen(covidrestrictions) item

* Replication Results
svy: regress covidconcern c.auth_2016##c.engagement age male black hispanic education income unemployed south 
margins, dydx(auth_2016) at (engagement=1)
svy: regress covidrestrictions c.auth_2016##c.engagement age male black hispanic education income unemployed south 
margins, dydx(auth_2016) at (engagement=1)

save VSG_Coded.dta, replace






